package com.chanyachting.emall.serviceImpl;

import java.util.List;

import com.chanyachting.emall.dao.BusinesstypeDAO;
import com.chanyachting.emall.domain.Businesscategory;
import com.chanyachting.emall.domain.Businesstype;
import com.chanyachting.emall.service.BusinesstypeService;

public class BusinesstypeServiceImpl implements BusinesstypeService {
	
	private BusinesstypeDAO btDao;

	public BusinesstypeServiceImpl() {
		
		this.btDao=new BusinesstypeDAO();
	}

	public boolean addBusinesstype(Businesstype by) {
		
		this.btDao.save(by);
		
		return true;
	}

	public boolean delBusinesstype(Businesstype by) {
		
		this.btDao.delete(by);
		
		return true;
	}

	public List<Businesstype> getAllBusinesstype() {
		
		return this.btDao.find("from Businesstype");
	}

	public List<Businesscategory> getBusinesscategoryByType(Businesstype by) {
		
		String args[]={String.valueOf(by.getId())};
		
		return this.btDao.find("from Businesscategory where businessTypeId=?",args);
	}

	public Businesstype getOneBusinesstype(Businesstype by) {
		
		return (Businesstype) this.btDao.load(Businesstype.class, by.getId());
	}

	public boolean updateBusinesstype(Businesstype by) {
		
		return this.btDao.updateBusinesstype(by);
	}

	public boolean updateBusinesstypePri(Businesstype by) {
		
		return this.btDao.updateBusinesstypePri(by);
	}

}
